package com.xs.ai.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import org.hibernate.annotations.Type;
import com.vladmihalcea.hibernate.type.json.JsonType;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

// ==========================================
// 任务实体
// ==========================================
@Data
@Entity
@Table(name = "tasks")
public class Task {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    private Long userId;
    private String title;
    
    @Column(columnDefinition = "TEXT")
    private String description;
    
    private String sourceType; // email, calendar, manual, ai_generated
    private Long sourceId;
    
    @Enumerated(EnumType.STRING)
    private TaskPriority priority;
    
    @Enumerated(EnumType.STRING)
    private TaskStatus status = TaskStatus.PENDING;
    
    private LocalDateTime dueDate;
    private LocalDateTime completedAt;
    
    // 委托
    private Long assignedToUserId;
    private LocalDateTime delegatedAt;
    
    @Column(columnDefinition = "TEXT")
    private String delegationNote;
    
    // AI建议
    @Column(columnDefinition = "TEXT")
    private String aiSuggestedAction;
    
    private Integer aiEstimatedTimeMinutes;
    
    @Type(JsonType.class)
    @Column(columnDefinition = "jsonb")
    private List<Long> aiDependencies;
    
    @Type(JsonType.class)
    @Column(columnDefinition = "jsonb")
    private List<String> tags;
    
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
}